package renderers
{
import org.osmf.layout.ScaleMode;

import spark.components.Image;
import spark.components.LabelItemRenderer;

public class NewsRenderer extends LabelItemRenderer
{
	private var img:Image;
    public function NewsRenderer()
    {
        super();
    }
    
    override public function set data(value:Object):void
    {
        super.data = value;
        
        invalidateDisplayList();
    }
	
	override protected function createChildren():void {
//		super.createChildren();
		img = new Image();
		img.scaleMode = ScaleMode.STRETCH;
		this.addChild(img);
	}
    
    override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
    {
        super.updateDisplayList(unscaledWidth, unscaledHeight);
//		img.source = data.source;
    }
	
	override protected function layoutContents(unscaledWidth:Number, 
											   unscaledHeight:Number):void
	{
		super.layoutContents(unscaledWidth, unscaledHeight);
		// layout all the subcomponents here      		
		if(data) img.source = data.source;
		this.setElementSize(img,unscaledWidth,unscaledHeight);
		this.setElementPosition(img,0,0);
	}
}
}